package vg.services.graph_view_manager.realization.graph_view.smart_graph_view.realization.actions;

import vg.services.data_base_manager.data.graph.Graph;
import vg.services.graph_view_manager.interfaces.graph_view.IGraphRenderer;
import vg.services.main_manager.MainManager;

import javax.swing.*;

/**
 * Returns selected subgraph.
 *
 * @author Timur Zolotuhin (e-mail: tzolotuhin@gmail.com)
 */
public class GetSelectedSubGraph extends DefaultActionAdapter {
    // Defines
    public static final int GET_COPY_SELECTED_SUBGRAPH_MODE = 1;
    public static final int GET_ORIGINAL_SELECTED_SUBGRAPH_MODE = 2;

    // Main data
    private Graph selectedSubGraph;

    private int mode = GET_COPY_SELECTED_SUBGRAPH_MODE;

    public GetSelectedSubGraph(int mode) {
        super("get selected subgraph");

        this.mode = mode;
    }

    @Override
    public void action(final IGraphRenderer graphRenderer) {
        switch (mode) {
            case GET_ORIGINAL_SELECTED_SUBGRAPH_MODE: {
                selectedSubGraph = graphRenderer.getOriginalSelectedSubGraph();
                break;
            }

            case GET_COPY_SELECTED_SUBGRAPH_MODE:
            default: {
                selectedSubGraph = graphRenderer.getCopySelectedSubGraph();
                break;
            }
        }

    }

    public Graph getSelectedSubGraph() {
        return selectedSubGraph;
    }
}
